package httputils

import (
	"encoding/json"
	"net/http"
	"server/components/logger"
)

type userIDCtxKey = struct{}

type EmptyResponse struct{}

var (
	UserIDCtxKey = userIDCtxKey{}
)

func WriteJson(w http.ResponseWriter, data interface{}) {
	w.Header().Add("Content-Type", "application/json")
	if err := json.NewEncoder(w).Encode(data); err != nil {
		logger.Logger().Errorf("cannot encode data %v", err)
	}
}
